import { memo, useMemo } from 'react';
import { observer } from 'mobx-react-lite';
import { Drawer, Descriptions } from 'antd';

import store from '@/store';
import { ResumeInfo } from '@/type';
import { DEGREE } from '@/constance';

export default memo(
    observer(function () {
        const { resume } = store.useStore();

        const drawerTitle = useMemo(() => {
            if (!resume.resumeDetailModalConfig.name) return '';
            return `${resume.resumeDetailModalConfig.name}的简历`;
        }, [resume.resumeDetailModalConfig.name]);

        const resumeInfo = useMemo<Partial<ResumeInfo>>(() => {
            const result = resume.resumeDetailModalConfig.result;
            return typeof result === 'string' ? {} : result;
        }, [resume.resumeDetailModalConfig.result]);

        return (
            <Drawer
                height={'100%'}
                loading={resume.resumeDetailModalConfig.loading}
                open={resume.resumeDetailModalConfig.visible}
                title={drawerTitle}
                placement={'top'}
                closable={false}
                onClose={resume.closeResumeDetailModal}
            >
                <Descriptions bordered layout="vertical" size="small">
                    <Descriptions.Item label="姓名" span={1.5}>
                        {resumeInfo?.basic_info?.name}
                    </Descriptions.Item>
                    <Descriptions.Item label="性别" span={1.5}>
                        {resumeInfo?.basic_info?.gender === 1 ? '男' : '女'}
                    </Descriptions.Item>
                    <Descriptions.Item label="年龄" span={1.5}>
                        {resumeInfo?.basic_info?.age || '未知'}
                    </Descriptions.Item>
                    <Descriptions.Item label="最高学历" span={1.5}>
                        {DEGREE[resumeInfo?.top_degree || 0]}
                    </Descriptions.Item>
                    <Descriptions.Item label="联系方式" span={1.5}>
                        {resumeInfo?.basic_info?.mobile || '未知'}
                    </Descriptions.Item>
                    <Descriptions.Item label="工作邮箱" span={1.5}>
                        {resumeInfo?.basic_info?.email || '未知'}
                    </Descriptions.Item>
                    <Descriptions.Item label="工作年限" span={1.5}>
                        {resumeInfo?.basic_info?.experience_years || '未知'}
                    </Descriptions.Item>
                    <Descriptions.Item label="婚姻状况" span={1.5}>
                        {resumeInfo?.basic_info?.marital_status === 1
                            ? '已婚'
                            : '未婚'}
                    </Descriptions.Item>
                    <Descriptions.Item label="教育经历" span={3}>
                        123123
                    </Descriptions.Item>
                    <Descriptions.Item label="工作经历" span={3}>
                        123123
                    </Descriptions.Item>
                    <Descriptions.Item label="项目经验" span={3}>
                        123123
                    </Descriptions.Item>
                </Descriptions>
            </Drawer>
        );
    })
);
